import { AccountType, RoleType } from "../types/user";
import request from "../utils/request";

//登录
export const userLogin = (account: AccountType) => {
  return request.post("login", account);
};

//账号分配【注册】
export const userReg = (account: AccountType) => {
  return request.post("users", account);
};

//账号列表
export const userGet = () => {
  return request.get("users");
};

//新增角色
export const rolePost = (roleData: Omit<RoleType, "objectId">) => {
  return request.post("classes/VueRole", roleData);
};

//角色列表、指定的角色
export const roleGet = (id?: string) => {
  let query = id ? `/${id}` : "";
  return request.get(`classes/VueRole${query}`);
};

//角色删除
export const roleDel = (id: string) => {
  return request.delete(`classes/VueRole/${id}`);
};

//编辑角色
export const rolePut = (id: string, roleData: Omit<RoleType, "objectId">) => {
  return request.put(`classes/VueRole/${id}`, roleData);
};
